/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jaywalkable.vkeyboard.impl;

import static com.jaywalkable.vkeyboard.BengaliLetter.*;
import static com.jaywalkable.vkeyboard.BengaliLetter.AI;
import static com.jaywalkable.vkeyboard.BengaliLetter.AU;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_EIGHT;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_FIVE;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_FOUR;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_NINE;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_ONE;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_SEVEN;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_SIX;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_THREE;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_TWO;
import static com.jaywalkable.vkeyboard.BengaliLetter.DIGIT_ZERO;
import static com.jaywalkable.vkeyboard.BengaliLetter.E;
import static com.jaywalkable.vkeyboard.BengaliLetter.I;
import static com.jaywalkable.vkeyboard.BengaliLetter.II;
import static com.jaywalkable.vkeyboard.BengaliLetter.O;
import static com.jaywalkable.vkeyboard.BengaliLetter.RUPEE_SIGN;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_AA;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_AI;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_AU;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_E;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_I;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_II;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_O;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_U;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_UU;
import static com.jaywalkable.vkeyboard.BengaliLetter.SIGN_VOCALIC_R;
import static com.jaywalkable.vkeyboard.BengaliLetter.U;
import static com.jaywalkable.vkeyboard.BengaliLetter.UU;
import static com.jaywalkable.vkeyboard.BengaliLetter.VOCALIC_L;
import static com.jaywalkable.vkeyboard.BengaliLetter.VOCALIC_R;

import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;

/**
 * This <code>abstract</code> class may be extended by implementations of <code>VKeyboardLayout</code> for bengali
 * alphabets only. Keyboard layout for numeric alphbets are mapped in this class.
 * 
 * @author Rubel Ahammad
 */
public abstract class AbstractBengaliVKeyboardLayoutImpl extends VKeyboardLayoutImpl implements BengaliVKeyboardLayout {
    protected final Character[] _Vowels = new Character[] { AA, I, II, E, AI, O, U, UU, AU, SIGN_AA, SIGN_I, SIGN_II,
            SIGN_E, SIGN_AI, SIGN_O, SIGN_U, SIGN_UU, SIGN_AU, VOCALIC_R, VOCALIC_L, SIGN_VOCALIC_R };

    protected final Character[] _NgaCategory = new Character[] { NGA, NYA, NNA, NA, MA, YA, SHA };

    public AbstractBengaliVKeyboardLayoutImpl() {
        layout.put(new Character[] { '0' }, new Character[] { DIGIT_ZERO });
        layout.put(new Character[] { '1' }, new Character[] { DIGIT_ONE });
        layout.put(new Character[] { '2' }, new Character[] { DIGIT_TWO });
        layout.put(new Character[] { '3' }, new Character[] { DIGIT_THREE });
        layout.put(new Character[] { '4' }, new Character[] { DIGIT_FOUR });
        layout.put(new Character[] { '5' }, new Character[] { DIGIT_FIVE });
        layout.put(new Character[] { '6' }, new Character[] { DIGIT_SIX });
        layout.put(new Character[] { '7' }, new Character[] { DIGIT_SEVEN });
        layout.put(new Character[] { '8' }, new Character[] { DIGIT_EIGHT });
        layout.put(new Character[] { '9' }, new Character[] { DIGIT_NINE });
        layout.put(new Character[] { '$' }, new Character[] { RUPEE_SIGN });
        layout.put(new Character[] { '`' }, new Character[] { ZERO_WIDTH_NON_JOINER });
        layout.put(new Character[] { '~' }, new Character[] { ZERO_WIDTH_JOINER });
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.jaywalkable.vkeyboard.impl.BengaliVKeyboardLayout#getSeparatorChar()
     */
    public Character getSeparatorChar() {
        return null;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.jaywalkable.vkeyboard.impl.BengaliVKeyboardLayout#isVowel(java.lang.Character)
     */
    public boolean isVowel(Character c) {
        return exists(_Vowels, c);
    }

    public boolean isNgaCategory(Character ch) {
        return exists(_NgaCategory, ch);
    }

    private boolean exists(Character[] list, Character searchChar) {
        for (int i = 0; i < _Vowels.length; i++) {
            if (_Vowels[i].equals(searchChar)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String transformVowel(Character preceedingChar, Character ch) {
        return null;
    }
}
